import { deepClone } from '@/utils/index'
export function getBarOptions(data) {
  const legend = deepClone(data).map((el) => {
    return el.groupName
  })
  const xAxis = deepClone(data[0].items).map((el) => {
    return el.time
  })
  const series = data.map((el) => {
    const itemData = el.items.map((item) => {
      return item.value
    })
    return {
      name: el.groupName,
      type: 'bar',
      barWidth: 20,
      data: itemData,
    }
  })
  const options = {
    legend: legend,
    grid: {
      top: '8%',
      left: '1%',
      right: '1%',
      bottom: '8%',
      containLabel: true,
    },
    xAxis: xAxis,
    series: series,
  }
  return options
}
